package apis

import (
	"LazyPig/models"
	"LazyPig/pkg/res"
	"github.com/gin-gonic/gin"
)

func Attendance(c *gin.Context)  {
	var row models.Row
	uid, _ := c.Get("uid")
	if err := c.Bind(&row); err != nil {
		return
	}
	if err := models.Attendance(&row, uid.(float64)); err != nil {
		c.JSON(res.FailedJson(err.Error()))
		return
	}
	c.JSON(res.SuccessJson(nil))
}

func GetAbList(c *gin.Context)  {
	uid, _ := c.Get("uid")
	rows, err := models.GetAbList(uid.(float64))
	if err != nil {
		c.JSON(res.FailedJson(err.Error()))
		return
	}
	c.JSON(res.SuccessJson(rows))
}

func GetAtList(c *gin.Context)  {
	uid, _ := c.Get("uid")
	rows, err := models.GetAtList(uid.(float64))
	if err != nil {
		c.JSON(res.FailedJson(err.Error()))
		return
	}
	c.JSON(res.SuccessJson(rows))
}
